﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using TimKen.BussLogic;
namespace TimKen.Web.UserControls
{
    public partial class Nav : TimKen.App.BaseUserControl
    {
        public decimal  totalCartCount = 0;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (CurrentUserName != null)
                {
                    this.tbUserLink.Visible = true;
                }
            }

            if (CurrentUserName != null)
            {
                ShoppingCartManager scm = new ShoppingCartManager();
                totalCartCount = scm.GetProductCountInCart(CurrentUserName);
            }
        }


        
        public string GetNewMessageAmount()
        {
            TimKen.BussLogic.InboxManager inboxM = new TimKen.BussLogic.InboxManager();

            DataSet ds = inboxM.GetCount(" ToID='" + CurrentUserName + "' and IsRead =0 and ToDelete=0");
            string newsAmount = ds.Tables[0].Rows[0]["total"].ToString();
            newsAmount = newsAmount == "0" ? "" : "<a href='/User/Inbox.aspx'>" + GetLangString("MenuInbox") + "(<span style='color:Red'>" + newsAmount + "</span>)</a>";
            return newsAmount;
        }

    }
}